<?php

namespace addons\shopro\controller;
use addons\shopro\model\UserWalletRecharge as Recharge;
class UserWalletRecharge extends Base
{

    protected $noNeedLogin = ['rule'];
    protected $noNeedRight = ['*'];


    public function index()
    {
        $this->success('充值记录', \addons\shopro\model\UserWalletRecharge::getList());
    }


    // 处理充值
    public function recharge()
    {
        checkEnv('yansongda');
        $type = $this->request->post('type');
        $money = $this->request->post('money');
        if (!$type || !in_array($type, ['wechat', 'alipay'])) {
            $this->error("支付类型不能为空");
        }
        $recharge = Recharge::recharge($type,$money);
        $this->success('充值订单创建成功', $recharge);
    }
}
